package Listdemo;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("JavaSE");
        list.add("JavaWeb");
        list.add("JavaEE");
        list.add("JVM");
        list.add("测试课程");
        System.out.println(list);
        System.out.println("===================for======================");

        for(int i = 0; i < list.size(); i++){
            System.out.println(list.get(i));
        }
        System.out.println("====================foreach======================");

        for (String x: list) {
            System.out.println(x);
        }

        System.out.println("====================迭代器1=======================");

        Iterator<String> it = list.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }

        System.out.println("====================迭代器2=======================");

        ListIterator<String> it2 = list.listIterator();
        while(it2.hasNext()){
            System.out.println(it2.next());
        }


        List<String> ret = list.subList(1,3);
        System.out.println(ret);

        System.out.println("===================更新===================");
        ret.set(0,"zmy");

        System.out.println(list);
        System.out.println(ret);
    }

    public static void main3(String[] args) {
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        arrayList1.add(1);
        arrayList1.add(2);
        arrayList1.add(3);
        System.out.println(arrayList1);
    }

    public static void main2(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(0,1);
        myArrayList.add(1,2);
        myArrayList.add(2,3);
        myArrayList.add(31);
        myArrayList.display();
        System.out.println(myArrayList.contains(1));
        System.out.println(myArrayList.indexOf(1));
        System.out.println(myArrayList.get(1));
        myArrayList.set(0,99);
        myArrayList.display();
    }

    public static void main1(String[] args) {
        List<Integer> list = new ArrayList<>();
        List<Integer> list2 = new LinkedList<>();
        List<Integer> list3 = new Stack<>();
        System.out.println("------------------------");
        ArrayList<Integer> list11 = new ArrayList<>();
        LinkedList<Integer> list22 = new LinkedList<>();
        Stack<Integer> list33 = new Stack<>();
    }
}
